<?php
class hrd_combo_model extends MY_Model {

	function listDivisi() {
		$ls_sql	= "	SELECT	ID_DIVISI_PK value,
							NAMA_DIVISI display
					FROM	HRD_DIVISI
					ORDER BY NAMA_DIVISI";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listDepartemenPerDivisi($kodeDivisi = '') {
		if($kodeDivisi != '') {
			$ls_sql	= "	SELECT	id_departemen_pk value,
								nama_departemen display 
						FROM	hrd_departemen 
						WHERE	id_departemen_fk = '".$kodeDivisi."'"." 
						ORDER BY display";
		}else{
			$ls_sql	= "	SELECT	id_departemen_pk value,
								nama_departemen display 
						FROM	hrd_departemen 
						ORDER BY display";
		}	

		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return NULL;
		}
	}

	function listDepartemen() {
		$ls_sql	= "	SELECT	ID_DEPARTEMEN_PK value,
							NAMA_DEPARTEMEN display
					FROM	HRD_DEPARTEMEN
					ORDER BY NAMA_DEPARTEMEN";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listLokasi() {
		/*$ls_sql	= "	SELECT	ID_lOKASI_PK value,
							NAMA_LOKASI display
					FROM	HRD_LOKASI
					ORDER BY NAMA_LOKASI";*/
		$ls_sql	= "	SELECT	KD_KANTOR value,
							NAMA_KANTOR display
					FROM	SW_KANTOR
					ORDER BY NAMA_KANTOR";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listJabatan() {
		$ls_sql	= "	SELECT	ID_JABATAN_PK value,
							NAMA_JABATAN display
					FROM	HRD_JABATAN
					ORDER BY NAMA_JABATAN";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listPangkat() {
		$ls_sql	= "	SELECT	ID_PANGKAT_PK value,
							NAMA_PANGKAT display
					FROM	HRD_PANGKAT
					ORDER BY NAMA_PANGKAT";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listStatusKontrak() {
		$ls_sql	= "	SELECT	ID_STATUS_KONTRAK_PK value,
							NAMA_KONTRAK display
					FROM	HRD_STATUS_KONTRAK
					where ID_STATUS_KONTRAK_PK != 'KP'
					ORDER BY NAMA_KONTRAK";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function semuaStatusKontrak() {
		$ls_sql	= "	SELECT	ID_STATUS_KONTRAK_PK value,
							NAMA_KONTRAK display
					FROM	HRD_STATUS_KONTRAK
					ORDER BY NAMA_KONTRAK";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listStatusKerja() {
		$ls_sql	= "	SELECT	ID_STATUS_KERJA_PK value,
							NAMA_STATUS_KERJA display
					FROM	HRD_STATUS_KERJA
					ORDER BY NAMA_STATUS_KERJA";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listSubDepartemen($kodeDepartemen = '') {
		if($kodeDepartemen != '') {
			$ls_sql	= "	SELECT	id_sub_departemen_pk value,
								nama_sub_departemen display 
						FROM	hrd_sub_departemen 
						WHERE	id_departemen_fk = '".$kodeDepartemen."'"." 
						ORDER BY display";
		}else{
			$ls_sql	= "	SELECT	id_sub_departemen_pk value,
								nama_sub_departemen display 
						FROM	hrd_sub_departemen 
						ORDER BY display";
		}	

		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return NULL;
		}
	}

	function listKelamin() {
		$ls_sql	= "	SELECT	GENDER_ID value,
							GENDER_NAME display
					FROM	SW_GENDER
					ORDER BY GENDER_NAME";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listAgama() {
		$ls_sql	= "	SELECT	ID_AGAMA_PK value,
							NAMA_AGAMA display
					FROM	SW_AGAMA
					ORDER BY NAMA_AGAMA";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listStatusKawin() {
		$ls_sql	= "	SELECT	ID_STATUS_KAWIN_PK value,
							NAMA_STATUS display
					FROM	HRD_STATUS_KAWIN
					ORDER BY ID_STATUS_KAWIN_PK";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listBank() {
		$ls_sql	= "	SELECT	KD_BANK value,
							NAMA_BANK display
					FROM	KEU_BANK
					ORDER BY NAMA_BANK";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listJenjang() {
		$ls_sql	= "	SELECT	ID_JENJANG_PK value,
							NAMA_JENJANG display
					FROM	HRD_JENJANG_PENDIDIKAN
					ORDER BY LEVEL_JENJANG";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listJurusan($kodeJenjang = '') {
		if($kodeJenjang != '') {
			$ls_sql	= "	SELECT	id_jurusan_pk value,
								nama_jurusan display 
						FROM	hrd_jurusan_pendidikan 
						WHERE	id_jenjang_fk = '".$kodeJenjang."'"." 
						ORDER BY display";
		}else{
			$ls_sql	= "	SELECT	id_jurusan_pk value,
								nama_jurusan display 
						FROM	hrd_jurusan_pendidikan 
						ORDER BY display";
		}	

		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return NULL;
		}
	}

	function listCostCenter() {
		$ls_sql	= "	SELECT	ID_COST_CENTER_PK value,
							NAMA_COST_CENTER display
					FROM	SW_COST_CENTER
					ORDER BY NAMA_COST_CENTER";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listKategoriBayar() {
		$ls_sql	= "	SELECT	ID_KATEGORI_BAYAR_PK value,
							NAMA_KATEGORI_BAYAR display
					FROM	HRD_KATEGORI_BAYAR
					ORDER BY NAMA_KATEGORI_BAYAR";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listGrubBayar() {
		$ls_sql	= "	SELECT	ID_GRUB_BAYAR_PK value,
							NAMA_GRUB_BAYAR display
					FROM	HRD_GRUB_KODE_BAYAR
					ORDER BY NAMA_GRUB_BAYAR";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listKodeBayar() {
		$ls_sql	= "	SELECT	ID_KODE_BAYAR_PK value,
							NAMA_KODE_BAYAR display
					FROM	HRD_KODE_BAYAR
					ORDER BY NAMA_KODE_BAYAR";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listPenghargaan() {
		$ls_sql	= "	SELECT	ID_PENGHARGAAN_PK value,
							NAMA_PENGHARGAAN display
					FROM	HRD_PENGHARGAAN
					ORDER BY NAMA_PENGHARGAAN ";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listPeringatan() {
		$ls_sql	= "	SELECT	ID_PERINGATAN_PK value,
							NAMA_PERINGATAN display
					FROM	HRD_PERINGATAN
					ORDER BY NAMA_PERINGATAN ";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listCountry() {
		$ls_sql	= "	SELECT	COUNTRY_CODE value,
							COUNTRY_NAME display
					FROM	SW_COUNTRY
					ORDER BY COUNTRY_NAME ";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listBobotKemampuan() {
		$ls_sql	= "	SELECT	id_bobot_kemampuan_pk value,
							nama_bobot_kemampuan display
					FROM	hrd_bobot_kemampuan
					ORDER BY nama_bobot_kemampuan ";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listMateriTes() {
		$ls_sql	= "	SELECT	id_materi_tes_pk value,
							nama_materi_tes display
					FROM	hrd_materi_tes
					ORDER BY nama_materi_tes ";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listGrubAbsen() {
		$ls_sql	= "	SELECT	ID_GRUB_ABSEN_PK value,
							NAMA_GRUB_ABSEN display
					FROM	HRD_GRUB_ABSEN
					ORDER BY NAMA_GRUB_ABSEN";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listPeriode() {
		$ls_sql	= "	SELECT	ID_PERIODE_PK value,
							NAMA_PERIODE display
					FROM	HRD_PERIODE
					ORDER BY TGL_MULAI DESC ";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	function listPeriodeThr() {
		$ls_sql	= "	SELECT	ID_PERIODE_THR_PK value,
							NAMA_PERIODE_THR display
					FROM	HRD_PERIODE_THR
					ORDER BY ID_PERIODE_THR_PK ASC ";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}

	/*function listShift() {
		$ls_sql	= "	SELECT	ID_SHIFT_PK value,
							NAMA_SHIFT display
					FROM	HRD_SHIFT
					ORDER BY URUTAN";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return array();
		}
	}*/

	function listShift() {
		$ls_sql	= "	SELECT	ID_SHIFT_PK value,
							NAMA_SHIFT display,
							jam_mulai, jam_selesai
					FROM	HRD_SHIFT
					ORDER BY URUTAN";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			foreach ($result->result_array() as $key => $value) {
				$data[] = array('value' => $value['value'], 
								'display' => $value['display'].' ['.$value['jam_mulai'].'-'.$value['jam_selesai'].']'
								);
			}
			return $data;
		}else{
			return array();
		}
	}

	function listStatusAbsen() {
		$ls_sql	= "	SELECT	ID_STATUS_ABSEN_PK value,
							NAMA_STATUS_ABSEN display
					FROM	HRD_STATUS_ABSEN
					ORDER BY URUTAN";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		} else {
			return array();
		}
	}

	function listJenisLembur() {
		$ls_sql	= "	SELECT	ID_JENIS_LEMBUR_PK value,
							NAMA_JENIS_LEMBUR display
					FROM	HRD_JENIS_LEMBUR
					ORDER BY NAMA_JENIS_LEMBUR ";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		} else {
			return array();
		}
	}

	function listPoinGaji() {
		$ls_sql	= "	SELECT	ID_POIN_GAJI_PK value,
							NAMA_POIN display
					FROM	HRD_POIN_GAJI
					WHERE status_organik=1
					ORDER BY ID_POIN_GAJI_PK ";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		} else {
			return array();
		}
	}

	function listPoinGajiKontrak() {
		$ls_sql	= "	SELECT	ID_POIN_GAJI_PK value,
							NAMA_POIN display
					FROM	HRD_POIN_GAJI
					WHERE status_organik=0
					ORDER BY ID_POIN_GAJI_PK ";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		} else {
			return array();
		}
	}

	function listJenisCuti() {
		$ls_sql	= "	SELECT	ID_JENIS_CUTI_PK value,
							ket_jenis_cuti display
					FROM	HRD_JENIS_CUTI
					ORDER BY ket_jenis_cuti ";
					
		$result	= $this->db->query($ls_sql);
		if($result->num_rows() > 0){
			return $result->result_array();
		} else {
			return array();
		}
	}
}